package com.ruoyi.teacher.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.teacher.api.RemoteTeacherService;
import com.ruoyi.teacher.api.domain.TeacherDto;
import com.ruoyi.teacher.api.domain.UserToTeacherDto;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 教师服务调用回退数据
 *
 * @author 陈立高
 * @date 2024/03/23
 */
@Component
public class RemoteTeacherFallbackFactory implements FallbackFactory<RemoteTeacherService> {
    @Override
    public RemoteTeacherService create(Throwable cause) {
        return new RemoteTeacherService() {
            @Override
            public R<Void> workNotification() {
                return R.fail("通知老师中心服务workNotification方法失败");
            }

            @Override
            public R<AjaxResult> loadTeacherTypeList() {
                return R.fail("远程调用老师中心服务loadTeacherTypeList方法失败");
            }

            @Override
            public R<Void> userToTeacher(UserToTeacherDto dto) {
                return R.fail("远程调用老师中心服务userToTeacher方法失败");
            }

            @Override
            public R<List<TeacherDto>> loadTeachers() {
                return R.fail("远程调用老师中心服务loadTeachers方法失败");
            }

            @Override
            public R<Void> attendanceSynchronization() {
                return R.fail("定时任务同步钉钉考勤失败");
            }

            @Override
            public R<Void> punchReminder() {
                return R.fail("通知打卡失败");
            }

            @Override
            public R<Void> abnormalTimingStatistics() {
                return R.fail("定时统计老师日志异常失败");
            }

            @Override
            public R<Void> timeNoticeTeacherReport() {
                return R.fail("定时任务失败，定时通知老师写日报");
            }

            @Override
            public R<Void> batchScheduling(Map<String, String> map) {
                return R.fail("批量排班失败");
            }
        };
    }
}
